/* 
 * MComboBoxUI.java
 * 本类重写了BasicComboBoxUI中部分功能以便使用自己的UI
 */
package org.vacoor.ui.qq.combobox;

import javax.swing.*;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;

/* 
 * @author Vacoor
 */
public class QQComboBoxUI extends BasicComboBoxUI {
    private QQComboBox MComboBox;

    public QQComboBoxUI(QQComboBox MComboBox) {
        this.MComboBox = MComboBox;
    }


    //重写显示或隐藏组合框的弹出部分按钮
    @Override
    protected JButton createArrowButton() {
//        UIManager.put("ComboBox.buttonBackground", Color.BLUE),
//        UIManager.put("ComboBox.buttonShadow", Color.BLACK);
//        UIManager.put("ComboBox.buttonDarkShadow", ),
//        UIManager.put("ComboBox.buttonHighlight")
//        BasicArrowButton btn = new BasicArrowButton(BasicArrowButton.SOUTH, Color.WHITE, Color.BLACK, new Color(0x5A88A4), Color.RED);
//        return btn;
        return new ArrowButton();
    }

    //可编辑的组合框中使用使用的编辑器
    @Override
    protected ComboBoxEditor createEditor() {
        new Color(11);
        return new QQComboBoxEditor(MComboBox);
    }

    //Popup菜单
    @Override
    protected ComboPopup createPopup() {
        return new QQComboBoxPopup(MComboBox);
    }

    //不可编辑的组合框中使用的渲染器。
    @Override
    protected ListCellRenderer createRenderer() {
        return new QQComboBoxListCellRender(MComboBox);
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setSize(400, 300);
        frame.add(new ArrowButton());
        frame.setVisible(true);
    }
}